package com.speily.base;

/**
 * @Auther: SPL
 * @Date: 2019-08-07 14:53
 * @Description: -
 */
public class StringTest {

    public static void main(String[] args) {

        //常量池
        String s1 = "abc";
        String s2 = "abc";
        String s3 = new String("abc");
        String s4 = s3.intern();//intern()方法能使一个位于堆中的字符串在运行期间动态地加入到字符串常量池中（字符串常量池的内容是程序启动的时候就已经加载好了）

        System.out.println(s1==s2);
        System.out.println(s1==s3);
        System.out.println(s1==s4);

        String s31 = new String("hello") + new String("hello");
        String s41 = "hellohello";
        String intern31 = s31.intern();
        System.out.println(s31 == s41);


    }

}
